//Date 2022.1.10
#include <stdio.h>
#include <stdlib.h>

float count_commossion(float number, float price);

int main(void)
{
    float number, price;
    printf("Enter the number of stocks: ");
    scanf("%f", &number);
    printf("Enter the price of each stock: ");
    scanf("%f", &price);
    printf("Commission: $%.2f\n", count_commossion(number, price));
    if (number < 2000)
    {
        printf("Competitor commission: $%.2f\n", count_commossion(number, 33.003f));
    }
    else
    {
        printf("Competitor commission: $%.2f\n", count_commossion(number, 33.002f));
    }
    system("pause");
    return 0;
}

float count_commossion(float number, float price)
{
    float commossion;
    if (number * price < 2500.00f)
    {
        commossion = 30.00f + 0.017f * number * price;
    }
    else if (number * price < 6250.00f)
    {
        commossion = 56.00f + 0.0066f * number * price;
    }
    else if (number * price < 20000.00f)
    {
        commossion = 76.00f + 0.0034f * number * price;
    }
    else if (number * price < 50000.00f)
    {
        commossion = 100.00f + 0.0022f * number * price;
    }
    else if (number * price < 500000.00f)
    {
        commossion = 155.00f + 0.0011f * number * price;
    }
    else
    {
        commossion = 255.00f + 0.0009f * number * price;
    }
    if (commossion < 39.00f)
    {
        commossion = 39.00f;
    }
    return commossion;
}